
/**
 * 显示完整的
 * @param {Array} item
 */
function SVG(item){
	this.item=item;
	this.width = 30;
	this.height = 30;
	// 设置展示svg内容的大小
	this.setSize = function (width,height){
		this.width = width;
		this.height = height;
	}
	this.draw=function(){
		var html = '';
		if( item!=undefined && item!=null && item.length>0){
			item.forEach(function(node){
				html+=node.draw();
			});
		}
		return '<svg xmlns="http://www.w3.org/2000/svg" width="'+this.width+'" height="'+this.height+'" version="1.1">'
		+ html +'<svg>';
	}
}

/**
 * 定义线条
 * @param {Number} x1 起点x
 * @param {Number} y1 起点y
 * @param {Number} x2 终点x
 * @param {Number} y2 终点y
 * @param {String} stroke 线条颜色
 * @param {String} strokeWidth 线条粗细 
 */
function line(x1,y1,x2,y2,stroke,strokeWidth){
	this.x1=x1;
	this.y1=y1;
	this.x2=x2;
	this.y2=y2;
	// 边界颜色
	this.stroke = stroke;
	// 边界宽度
	this.strokeWidth = strokeWidth;
	this.setValues = function(x1,y1,x2,y2,stroke,strokeWidth){
		this.x1=x1;
		this.y1=y1;
		this.x2=x2;
		this.y2=y2;
		this.stroke = stroke;
		this.strokeWidth = strokeWidth;
	}
	this.draw = function(){
		return '<line x1="'+this.x1+'" y1="'+this.y1+'"'
		    +' x2="'+this.x2+'" y2="'+this.y2+'" '
			+'style="stroke:'+this.stroke+';stroke-width:'+this.strokeWidth+'"/>';
	}
}
/**
 * 定义文本内容
 * @param {Number} x
 * @param {Number} y
 * @param {String} fill 填充颜色
 * @param {String} txt 显示文本
 */
function text(x,y,fill,txt){
	this.x = x;
	this.y = y;
	this.fill = fill;
	this.txt = txt;
	this.setValues = function(x,y,fill,txt){
		this.x = x;
		this.y = y;
		this.fill = fill;
		this.txt = txt;
	}
	this.draw=function(){
		return '<text x="'+this.x+'" y="'+this.y+'" fill="'+this.fill+'">'+this.txt+'</text>';
	}
}
/**
 * 定义SVG一个圆圈的内容
 * @param {Number} cx 圆心x
 * @param {Number} cy 圆心y
 * @param {Number} r 半径
 * @param {String} stroke 线条颜色
 * @param {String} strokeWidth 线条粗细
 * @param {String} fill 填充颜色
 */
function circle(cx,cy,r,stroke,strokeWidth,fill){
	// 一个圆圈的基本信息
	// 圆心x
	this.cx = cx;
	// 圆心Y值
	this.cy = cy;
	// 半径
	this.r = r;
	// 边界颜色
	this.stroke = stroke;
	// 边界宽度
	this.strokeWidth = strokeWidth;
	// 填充颜色
	this.fill=fill;
	this.setValues = function(cx,cy,r,stroke,strokeWidth,fill){
		this.cx = cx;
		this.cy = cy;
		this.r = r;
		this.stroke = stroke;
		this.strokeWidth = strokeWidth;
		this.fill=fill;
	}
	this.draw=function(){
		return '<ellipse cx="'+this.cx+'" cy="'+this.cy+'" rx="'+this.r+'" ry="'+this.r+'"' +
				'style="fill:'+this.fill+';stroke:'+this.stroke+';stroke-width:'+this.strokeWidth+'"/>';
	}
}